package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DzZhoubian;
import com.ruoyi.system.service.IDzZhoubianService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 周边配套Controller
 * 
 * @author ruoyi
 * @date 2023-08-16
 */
@RestController
@RequestMapping("/system/zhoubian")
public class DzZhoubianController extends BaseController
{
    @Autowired
    private IDzZhoubianService dzZhoubianService;

    /**
     * 查询周边配套列表
     */
    @GetMapping("/list")
    public TableDataInfo list(DzZhoubian dzZhoubian)
    {
        startPage();
        List<DzZhoubian> list = dzZhoubianService.selectDzZhoubianList(dzZhoubian);
        return getDataTable(list);
    }

    /**
     * 导出周边配套列表
     */
    @Log(title = "周边配套", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DzZhoubian dzZhoubian)
    {
        List<DzZhoubian> list = dzZhoubianService.selectDzZhoubianList(dzZhoubian);
        ExcelUtil<DzZhoubian> util = new ExcelUtil<DzZhoubian>(DzZhoubian.class);
        util.exportExcel(response, list, "周边配套数据");
    }

    /**
     * 获取周边配套详细信息
     */
    @GetMapping(value = "/{zbId}")
    public AjaxResult getInfo(@PathVariable("zbId") Long zbId)
    {
        return AjaxResult.success(dzZhoubianService.selectDzZhoubianByZbId(zbId));
    }

    /**
     * 新增周边配套
     */
    @Log(title = "周边配套", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DzZhoubian dzZhoubian)
    {
        return toAjax(dzZhoubianService.insertDzZhoubian(dzZhoubian));
    }

    /**
     * 修改周边配套
     */
    @Log(title = "周边配套", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DzZhoubian dzZhoubian)
    {
        return toAjax(dzZhoubianService.updateDzZhoubian(dzZhoubian));
    }

    /**
     * 删除周边配套
     */
    @Log(title = "周边配套", businessType = BusinessType.DELETE)
	@DeleteMapping("/{zbIds}")
    public AjaxResult remove(@PathVariable Long[] zbIds)
    {
        return toAjax(dzZhoubianService.deleteDzZhoubianByZbIds(zbIds));
    }
}
